#include<iostream>
using namespace std;
const int N = 1e6 + 10;
int arr[N];
int d[N];
int n, m;
void get_sum()
{
	d[0] = arr[0];
	for (int i = 1; i < n; i++) {
		d[i] = d[i - 1] + arr[i];
	}
}
int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	get_sum();
	while (m--) {
		int l, r;
		cin >> l >> r;
		cout << d[r] - d[l - 1] << endl;
	}
	return 0;
}